package com.zougen202301180355.restaurant.service.impl;

import com.zougen202301180355.restaurant.mapper.CustomersMapper;
import com.zougen202301180355.restaurant.pojo.Customer;
import com.zougen202301180355.restaurant.service.CustomersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 邹根
 * 顾客服务实现类
 */
@Service
@Transactional
public class CustomersServiceImpl implements CustomersService {

    @Autowired
    private CustomersMapper customersMapper;

    @Override
    public void addCustomer(Customer customer) {
        customersMapper.insert(customer);
    }

    @Override
    public void deleteCustomer(Integer id) {
        customersMapper.delete(id);
    }

    @Override
    public void updateCustomer(Customer customer) {
        customersMapper.update(customer);
    }

    @Override
    public Customer getCustomerById(Integer id) {
        return customersMapper.selectById(id);
    }

    @Override
    public List<Customer> getAllCustomers() {
        return customersMapper.selectAll();
    }

    @Override
    public Customer getCustomerWithOrders(Integer id) {
        return customersMapper.selectWithOrders(id);
    }
}
